package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.PsyTest;
import com.lanou.mapper.PsyTestMapper;
import com.lanou.service.PsyTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName PsyTestServiceImpl
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年08月13日 16:34
 * @Version 1.0
 */
@Service
public class PsyTestServiceImpl implements PsyTestService {
    @Autowired
    private PsyTestMapper psyTestMapper;

    @Override
    public PsyTest getPsyTest(Integer id) {
        return psyTestMapper.selectPsyTestById(id);
    }

    @Override
    public PageInfo<PsyTest> getPsyTests(PsyTest psyTest, Integer pageNum, Integer pageSize) {
        if(pageNum==null&&pageSize==null){
            PageInfo<PsyTest> pageInfo= new PageInfo<>(psyTestMapper.selectPsyTestList(psyTest));
            return pageInfo;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<PsyTest> psyTests=psyTestMapper.selectPsyTestList(psyTest);
        PageInfo<PsyTest> pageInfo=new PageInfo<>(psyTests);
        return pageInfo;
    }
}
